package com.qf.mybatisplus.controller;

import com.qf.mybatisplus.entity.Student;
import com.qf.mybatisplus.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stu")
public class StuController {
    @Autowired
    private StuService stuService;
    @PostMapping("/insert")
    public String insert(Student student){
        stuService.insert(student);
        System.out.println("新增学生成功："+student);
        return "新增成功";
    }
    @GetMapping("/list")
    public List<Student> list(){
        return stuService.list();
    }
}
